package ca.on.eho.qa.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.support.ui.WebDriverWait;

import ca.on.eho.qa.pages.PageManager;
import ca.on.eho.qa.util.Constants;

/*
 * Abstract class representation of a Page in the UI. Page object pattern
 * 
 * Created on: Oct-15-2014
 * Created by: @LS
 * Change log:
 * 
 */

public abstract class Page {

	protected PageManager pages;
	protected WebDriver driver;
	protected WebDriverWait wait;

	public Page(PageManager pages) {
		this.pages = pages;
		driver = pages.getWebDriver();
		wait = new WebDriverWait(driver, Constants.MEDIUM_WAIT);
	}

	public WebDriver getWebDriver() {
		return driver;
	}

	public String getTitle() {
		return driver.getTitle();
	}
	
	public Page ensurePageLoaded() {
		return this;
	}
	
	public boolean waitPageLoaded() {
		try {
			ensurePageLoaded();
			return true;
		} catch (TimeoutException te) {
			return false;
		}
	}

}
